<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    table{
        border: solid 1px;
        width: 280px;
    }
</style>
<body>
    <h1>添加博客或者修改</h1>
    <table>
        <tr>
            <td>标题：</td>
            <td><input type="text" id="title"></td>
        </tr>
        <tr>
            <td>摘要：</td>
            <td><input type="text" id="abstract"></td>
        </tr>
        <tr>
            <td>内容：</td>
            <td><input type="text" id="details"></td>
        </tr>
        <tr>
            <td>分类：</td>
            <td><input type="text" id="classify"></td>
        </tr>
        <tr>
            <td>作者：</td>
            <td><input type="text" id="author"></td>
        </tr>
        <tr>
            <td><input type="button" value="保存" onclick="save()"></td>
            <td><input type="button" value="取消" onclick="cancer()"></td>
        </tr>
    </table>
    
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./js/init.js"></script>
    <script>
        let id = window.location.href.split('?')[1]
        console.log(id);
        if (id) {
            $.ajax({
                url: `http://localhost:8000/find`,
                type: 'post',
                data: { id },
                success: data => {
                    $('#title').val(data[0].title),
                        $('#abstract').val(data[0].abstract),
                        $('#details').val(data[0].details),
                        $('#classify').val(data[0].classify),
                        $('#author').val(data[0].author)
                }

            })
        }

    </script>
</body>

</html>